using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;

using Module.DataAccess;
using Module.EntitiesInfo;

namespace Module.BusinessLogic
{
    public class CMSFootballPlayer
	{	
		public static int Insert(CMSFootballPlayerInfo cMSFootballPlayerInfo)
		{
			try
			{
                DataCach.DataCach cache = new DataCach.DataCach();
                cache.RemoveAll();
				return new CMSFootballPlayerDB().Insert(cMSFootballPlayerInfo);              
			}
			catch (Exception ex)
			{
				throw;
			}

		}
	
		public static void Update(CMSFootballPlayerInfo cMSFootballPlayerInfo)
		{
			try
			{
				new CMSFootballPlayerDB().Update(cMSFootballPlayerInfo);
                DataCach.DataCach cache = new DataCach.DataCach();
                cache.RemoveAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}
		
		public static void Delete(int footBallId)
		{
			try
			{
				new CMSFootballPlayerDB().Delete(footBallId);
                DataCach.DataCach cache = new DataCach.DataCach();
                cache.RemoveAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}

        public static CMSFootballPlayerInfo GetInfo(int id)
        {
            try
            {
                CMSFootballPlayerInfo info;
                info = ObjectHelper.FillObject<CMSFootballPlayerInfo>(new CMSFootballPlayerDB().GetInfo(id));
                if (info != null)
                    return info;
                return null;
            }
            catch (Exception)
            {
                throw;
            }
        }

        
        public static int GetCount(string keysearch,int clubId, int status, DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow)
        {
            try
            {
                return new CMSFootballPlayerDB().GetCount(keysearch,clubId,status, starDatetime, endDatetime, beginRow, endRow);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static DataTable Search(string keysearch,int clubId, int status, DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new CMSFootballPlayerDB().Search(keysearch,clubId,status, starDatetime, endDatetime, beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        public static void UpdateStatus(int footBallId, int status, int param)
        {
            try
            {
                new CMSFootballPlayerDB().UpdateStatus(footBallId, status, param);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        #region Outsite
        public static int GetCount()
        {
            try
            {
                DataCach.DataCach cache = new DataCach.DataCach();
                string strCache = "{DDE0628C-B814-419C-8CE4-930BB871F7CF}";
                int count=0;
                if (cache.GetCache(strCache) != null)
                {
                    count = (int)(cache.GetCache(strCache));
                    return count;
                }
                count=new CMSFootballPlayerDB().GetCount();
                if (count > 0)
                {
                    cache.InsertCache(strCache, count,
                                      Convert.ToDouble(ConfigurationSettings.AppSettings["timeCache"].ToString()));
                }
                return count;
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static DataTable Getlist(int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                DataCach.DataCach cache = new DataCach.DataCach();
                string strCache =beginRow + "_" + endRow + "_" + orderByColumn + "{A6709A8B-AA39-4E5D-B277-6E32850FC34B}";
                DataTable dt = new DataTable();
                if (cache.GetCache(strCache) != null)
                {
                    dt = (DataTable)(cache.GetCache(strCache));
                    return dt;
                }
                dt=new CMSFootballPlayerDB().Getlist(beginRow, endRow, orderByColumn);
                if(dt !=null && dt.Rows.Count > 0)
                {
                    cache.InsertCache(strCache, dt, Convert.ToDouble(ConfigurationSettings.AppSettings["timeCache"].ToString()));
                }
                return dt;
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static CMSFootballPlayerInfo GetInfoOutsite(int id)
        {
            try
            {
                DataCach.DataCach cache = new DataCach.DataCach();
                string strCache = id + "_{75EF1413-0D9E-4A4B-AF2B-2F6967A5909A}";
                CMSFootballPlayerInfo info=new CMSFootballPlayerInfo();
                if (cache.GetCache(strCache) != null)
                {
                    info = (CMSFootballPlayerInfo)(cache.GetCache(strCache));
                    return info;
                }
                info = ObjectHelper.FillObject<CMSFootballPlayerInfo>(new CMSFootballPlayerDB().GetInfo(id));
                if (info != null)
                {
                    cache.InsertCache(strCache, info, Convert.ToDouble(ConfigurationSettings.AppSettings["timeCache"].ToString()));
                }
                return info;                                             
            }
            catch (Exception)
            {
                throw;
            }
        }
        #endregion
    }
}
